import axios from "axios";
import { GET_TODO_LIST } from "./actionTypes";
import { initListAction } from "./actionCreators";
import { put, takeLatest } from "@redux-saga/core/effects";

function* getTodoList() {
	try {
		const res = yield axios.get("/mock/list.json");
		const action = initListAction(res.data);
		yield put(action);
	} catch (error) {
		console.log("网络异常");
	}
}

function* mySaga() {
	yield takeLatest(GET_TODO_LIST, getTodoList);
}

export default mySaga;
